function [psss_symbols, psss_time_domain, psss_indices] = Function_Generate_PSS(slMode, NSLRB, NSLID, N_pss_cazac, NRBsc, cpLenR, NFFT, cp_Len_r12)
	%Create Primary Sync Signals (36.211, 9.7.1)
            
	%% Create PSS signals
	if slMode == 0 % legacy LTE mode, not fully tested/supported yet
        nid_2 = mod(NSLID,3); num_nid2s = length(nid_2);
        ZC_ind = [25; 29; 34];
  	elseif slMode > 0 % sidelink mode
        nid_2 = zeros(size(NSLID));
        nid_2(NSLID>167) = 1;
      	num_nid2s = length(nid_2);
    	ZC_ind = [26, 37];
    end
            
  	% Initialization of output sequence matrix:
	psss_symbols = complex(zeros(N_pss_cazac-1, num_nid2s));
            
	n_ind = (0:N_pss_cazac-1)';
 	counter = 1;
	for ii = nid_2
      	jj = ii + 1;
        tmp = sqrt(72/(N_pss_cazac-1))*exp(-1i*pi*ZC_ind(jj)*n_ind.*(n_ind+1)/N_pss_cazac);
        psss_symbols(:, counter) = tmp([1:(N_pss_cazac-1)/2 (N_pss_cazac-1)/2+2:N_pss_cazac], 1);
        counter = counter + 1;
    end
            
	%% Create PSSS indices
 	Nsc = NSLRB*NRBsc;
            
	if slMode > 0 % sidelink mode
      	psss_symbols = [psss_symbols; psss_symbols];
        if strcmp(cp_Len_r12, 'Normal')
            psss_indices = [(Nsc+Nsc/2-(N_pss_cazac-1)/2+1: Nsc+Nsc/2+(N_pss_cazac-1)/2) (2*Nsc+Nsc/2-(N_pss_cazac-1)/2+1: 2*Nsc+Nsc/2+(N_pss_cazac-1)/2)];
      	elseif strcmp(h.cp_Len_r12, 'Extended')
        	psss_indices = [(Nsc/2-(N_pss_cazac-1)/2+1: Nsc/2+(N_pss_cazac-1)/2) (Nsc+Nsc/2-(N_pss_cazac-1)/2+1: Nsc+Nsc/2+(N_pss_cazac-1)/2)];
        end
  	elseif slMode == 0 % legacy LTE mode, not fully tested/supported yet
        if strcmp(cp_Len_r12, 'Normal')
        	psss_indices = (6*Nsc+Nsc/2-(N_pss_cazac-1)/2+1: 6*Nsc+Nsc/2+(N_pss_cazac-1)/2);
      	elseif strcmp(cp_Len_r12, 'Extended')
            psss_indices = (5*Nsc+Nsc/2-(N_pss_cazac-1)/2+1: 5*Nsc+Nsc/2+(N_pss_cazac-1)/2);
        end
    end
            
	%% Create time domain signal:
	tmp = zeros(NFFT, 1);
	if slMode > 0 % sidelink mode
        tmp(NFFT/2-(N_pss_cazac-1)/2+1:NFFT/2+(N_pss_cazac-1)/2) = psss_symbols(1:N_pss_cazac-1);
 	elseif slMode == 0 % legacy LTE mode, not fully tested/supported yet
        ind = [(NFFT/2-(N_pss_cazac-1)/2:NFFT/2);  (NFFT/2+2:(N_pss_cazac-1)/2+1)] ;
        tmp(ind) =  psss_symbols(1:N_pss_cazac-1);
    end
            
	% IFFT
	Tmp = ifft(ifftshift(tmp));
	% Normalize power:
	Tmp = NFFT/sqrt(NSLRB*NRBsc)*Tmp;
	% Add CP:
	Tmp = [Tmp(end-cpLenR+1:end); Tmp]; 
	% Shift by half subcarrier:
	psss_time_domain = Tmp.*exp(2i*pi*(-cpLenR:NFFT-1)'/NFFT/2);
            
end %  create_pss